package org.seeplnframework.skyeye.common.enums;

import java.util.Arrays;

/**
 * MDC常量枚举
 */
public enum MDCConstantEnum {

    ERROR_MESSAGE("errorMessage", "异常信息"),
    SERVER_NAME("ApplicationName", "服务名称"),
    SOURCE_IP("sourceIP", "来源IP"),
    SERVER_IP("serverIP", "IP"),
    SERVER_HOSTNAME("serverHostname", "服务器hostname"),
    OCCURRENCE_TIME("occurrenceTime", "发生时间"),
    REQUEST_TYPE("requestType", "请求类型"),
    TRACE_ID("traceId", "跟踪traceId"),
    REQUEST_URI("requestURI", "源"),
    REQUEST_PARAM("requestParam", "请求参数"),
    REQUEST_HEADER("requestHeader", "请求头"),
    MQ_TYPE("mqType", "MQ类型"),
    CONSUMER_GROUP("consumerGroup", "消费组"),
    MESSAGE_TOPIC("messageTopic", "消息topic"),
    MESSAGE_ID("messageId", "消息msgId"),
    MESSAGE_KEYS("messageKeys", "消息keys"),
    EVENT_NAME("eventName", "事件name"),
    EVENT_PAYLOAD("eventPayload", "事件payload"),
    EXCEPTION_MESSAGE("exceptionMessage", "异常信息"),
    EXCEPTION_STACKTRACE("exceptionStackTrace", "异常堆栈"),
    DEPLOY_TAG("deployTag", "部署tag号"),
    GIT_VERSION("gitVersion", "git版本"),
    PROFILES_ACTIVE("profilesActive", "profile配置"),
    SYSTEM_DESC("systemDesc", "系统描述"),
    EXCEPTION_TYPE("exceptionType", "异常类型"),
    INVOKE_METHOD("invokeMethod", "调用方法"),
    INVOKE_PARAM("invokeParam", "调用参数"),
    INVOKE_PARAM_TYPE("invokeParamType", "参数类型"),
    INVOKE_DETAIL("invokeDetail", "调用详情"),
    INVOKE_CHANNEL("invokeChannel", "调用通道"),
    BUSINESS_APP("app", "app"),
    BUSINESS_USER("user", "user"),
    BUSINESS_SPACE("space", "space"),
    BUSINESS_TENANT_CODE("tenant-code", "tenant-code"),
    POD_NAME("pod-name","Pod"),
    CONTAINER_NAME("container-name","Container"),
    NAMESPACE("namespace","Namespace");

    private String code;
    private String name;

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    MDCConstantEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static MDCConstantEnum getByValue(String code) {
        return Arrays.stream(MDCConstantEnum.values())
                .filter(resultCodeEnum -> resultCodeEnum.code.equals(code))
                .findFirst().orElse(null);
    }
}
